/**
 * @FileName: SentenceTrunk.java
 * @Package: top.swimmer.demo.entity
 * @author youshipeng
 * @created 2017/4/27 8:33
 * <p>
 * Copyright 2016 ziroom
 */
package top.swimmer.demo.entity;

import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.IndexedWord;

/**
 * <p></p>
 *
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author youshipeng
 * @since 1.0
 * @version 1.0
 */
public class SentenceTrunk {
    /**
     * 主语
     */
    public IndexedWord subject;
    /**
     * 谓语
     */
    public IndexedWord predicate;
    /**
     * 宾语
     */
    public IndexedWord object;

    public String result;

    public SentenceTrunk() {}

    public SentenceTrunk(IndexedWord predicate) {
        this.predicate = predicate;
    }

    public void done()
    {
        result = predicate.toString(CoreLabel.OutputFormat.VALUE);
        if (subject != null)
        {
            result = subject.toString(CoreLabel.OutputFormat.VALUE) + result;
        }
        if (object != null)
        {
            result = result  + object.toString(CoreLabel.OutputFormat.VALUE);
        }
    }

    public boolean isDone()
    {
        return result != null;
    }

    @Override
    public String toString()
    {
        if (result != null) return result;
        return "MainPart{" +
                "主语='" + subject + '\'' +
                ", 谓语='" + predicate + '\'' +
                ", 宾语='" + object + '\'' +
                '}';
    }
}